<template>
  <div>
    <van-swipe
      class="my-swipe"
      :vertical="list.vertical"
      :autoplay="list.autoplay||3000"
      indicator-color="white"
      @change="onChange"
    >
      <van-swipe-item v-for="(item,index) in list.img" :key="index">
        <img v-lazy="item.img" alt="">
      </van-swipe-item>

      <template v-if="list.flag" #indicator>
        <div class="custom-indicator">{{ current + 1 }}/{{list.img.length}}</div>
      </template>
    </van-swipe>
  </div>
</template>

<script>
export default {
  data() {
    return {
      key: "",
      current: 1,
    };
  },
  props: ["list"],
  methods:{
      onChange(index) {
      this.current = index;
    },
  }
};
</script>

<style >
.my-swipe {
  height: 200px;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
  width: 100%;
  height: 200px;
}
.custom-indicator {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 5px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.1);
}
</style>